<?php
use Jialeo\LaravelSchemaExtend\Schema;
//use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopSkusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_product_types', function (Blueprint $table) {
			$table->comment = '商品分类表';
            $table->increments('id')->comment('分类ID');
			$table->string('title')->default('')->comment('分类名称');
			$table->integer('image_id')->nullable()->comment('图片id');
			$table->integer('pid')->default(0)->comment('父级分类ID');
			$table->tinyInteger('level')->default(1)->comment('分类级别默认为一级');
			$table->tinyInteger('status')->default(1)->comment('显示状态:0=隐藏,1=显示');
			$table->integer('sort')->default(1)->comment('排序');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');
        }); 
		Schema::create('shop_product_attrbute_keys', function (Blueprint $table) {
            $table->comment = '商品属性表';
            $table->increments('id')->comment('商品属性ID');
			$table->integer('product_type_id')->nullable()->comment('商品分类id');
			$table->string('name')->default('')->comment('属性名称');
			$table->integer('sort')->default(1)->comment('排序');
			$table->tinyInteger('status')->default(1)->comment('显示状态:0=隐藏,1=显示');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');
        });
		Schema::create('shop_product_attrbute_values', function (Blueprint $table) {
            $table->comment = '商品属性值表';
            $table->increments('id')->comment('商品属性值ID');
			$table->integer('attrbute_key_id')->nullable()->comment('商品属性id');
			$table->string('value')->default('')->comment('属性值');
			$table->integer('sort')->default(1)->comment('排序');
			$table->tinyInteger('status')->default(1)->comment('显示状态:0=隐藏,1=显示');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间'); 
        });
        Schema::create('shop_products', function (Blueprint $table) {
            $table->comment = '商品表';
            $table->increments('id')->comment('商品ID');
			$table->integer('product_type_id')->nullable()->comment('商品分类id');
			$table->string('name')->default('')->comment('商品名称');
			$table->string('describe')->default('')->comment('商品描述');
			$table->integer('image_id')->nullable()->comment('图片id');
			$table->string('images')->nullable()->comment('轮播图：多个用|隔开');
			$table->text('attrbute_list')->nullable()->comment('前端展示多条sku的json数据');
			$table->text('content')->nullable()->comment('商品详情');
			$table->tinyInteger('status')->default(0)->comment('状态:0=下架,1=上架');
			$table->tinyInteger('specs_status')->default(0)->comment('是否有规格:0=否,1=是');
			$table->tinyInteger('recommend_status')->default(0)->comment('是否精品推荐:0=否,1=是');
			$table->tinyInteger('best_status')->default(0)->comment('是否热卖单品:0=否,1=是');
			$table->integer('sort')->default(1)->comment('排序');
			$table->integer('sales')->default('0')->comment('销量（是规格表中的总和）');
			$table->decimal('money',8,2)->default('0.00')->comment('产品售价（是规格表中的第一个价格）');
			$table->decimal('bazaar_money',8,2)->default('0.00')->comment('产品市场价（是规格表中的第一个价格）');
			$table->decimal('postage',8,2)->default('0.00')->comment('邮费（是规格表中的第一个价格）');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');
			$table->tinyInteger('is_delete')->default(0)->comment('是否删除:0=否,1=是');
        });
		Schema::create('shop_product_specs', function (Blueprint $table) {
            $table->comment = '商品规格表';
            $table->increments('id')->comment('商品规格ID');
			$table->integer('product_id')->nullable()->comment('商品id');
			$table->string('specs')->default('')->comment('单条sku的json数据');
			$table->decimal('money',8,2)->default('0.00')->comment('产品售价');
			$table->decimal('bazaar_money',8,2)->default('0.00')->comment('产品市场价');
			$table->decimal('cost_money',8,2)->default('0.00')->comment('产品成本价');
			$table->decimal('postage',8,2)->default('0.00')->comment('邮费');
			$table->integer('stock')->default('0')->comment('库存');
			$table->integer('sales')->default('0')->comment('销量');
			$table->string('sku')->default('')->comment('单条sku_id');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('updated_at')->nullable()->comment('更新时间');
        });
		
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_product_types');
        Schema::dropIfExists('shop_products');
        Schema::dropIfExists('shop_product_specs');
        Schema::dropIfExists('shop_product_attrbute_keys');
        Schema::dropIfExists('shop_product_attrbute_values');
    }
}
